package com.ee.chat.admin.controller.operatemanage;

import com.ee.chat.admin.service.ISensitiveWordService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author AppiJ
 * @Date 2020/4/8 16:39
 */
@RestController
@RequestMapping("sensitiveWord")
public class SensitiveWordController {
    private Logger log = LoggerFactory.getLogger(SensitiveWordController.class);

    @Resource
    ISensitiveWordService sensitiveWordService;

    /**
     * 获取敏感词列表
     * @Author AppiJ
     * @Date 2020/4/8 17:09
     * @param
     * @return
     */
    @RequestMapping("list")
    public Result list(HttpServletRequest request, String word, Integer status, String createTime,
                       @RequestParam Integer page, @RequestParam Integer limit){
        try{
            return sensitiveWordService.list(request, word, status, createTime, page, limit);
        }catch (Exception e){
            log.error("【获取敏感词列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 添加敏感词
     * @Author AppiJ
     * @Date 2020/4/8 18:01
     * @param
     * @return
     */
    @RequestMapping("add")
    public Result add(HttpServletRequest request, @RequestParam String word){
        try{
            return sensitiveWordService.add(request, word);
        }catch (Exception e){
            log.error("【添加敏感词错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 修改敏感词状态
     * @Author AppiJ
     * @Date 2020/4/8 18:29
     * @param
     * @return
     */
    @RequestMapping("updateStatus")
    public Result updateStatus(HttpServletRequest request, @RequestParam Integer id){
        try{
            return sensitiveWordService.updateStatus(request, id);
        }catch (Exception e){
            log.error("【修改敏感词状态错误】", e);
        }
        return Result.returnFailure();
    }

}
